/* -----------------------------------------------------------------------
 * Demonstration of how to write unit tests for dominion-base
 * Include the following lines in your makefile:
 *
 * unittest1: unittest1.c dominion.o rngs.o
 *      gcc -o testUpdateCoins -g  unittest1.c dominion.o rngs.o $(CFLAGS)
 * -----------------------------------------------------------------------
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int main() {
	//testing isGameOver
	struct gameState G;
	int numPlayer = 2;
	int seed = 2;
	int player = 0;//just player 0 for now
	int k[10] = {adventurer, council_room, feast, gardens, mine
		, remodel, smithy, village, baron, great_hall};
	
	int r = initializeGame(numPlayer, k, seed, &G); // initialize a new game

	int gameOverTest;
	int x= G.supplyCount[province];//set x to the count of provinces
	char passOrFail[256]= "Passed normal test";
	
	for (x; x>=0; x--) {//decrement the amount of provinces and test for normal behavior
		gameOverTest = isGameOver(&G);
		//printf("provinceCount: %d\n",G.supplyCount[province]); 
		G.supplyCount[province]=x;
		//printf("Game state is: %d\n",gameOverTest);
		
		if (gameOverTest==1) {
			strncpy(passOrFail, "Failed normal test", sizeof (passOrFail));
		}
	}
	printf("%s\n", passOrFail);

	
	//test for too low
	strncpy(passOrFail, "Passed out of bounds test", sizeof (passOrFail));
	G.supplyCount[province]=-1;
	gameOverTest = isGameOver(&G);
	if (gameOverTest==0) {//meaning the game is still going
		strncpy(passOrFail, "Failed out of bounds test", sizeof (passOrFail));
	}
	printf("%s\n", passOrFail);
	G.supplyCount[province]=8;//put it back to normal
	
	//test normal supply game end
	strncpy(passOrFail, "Passed supply test", sizeof (passOrFail));
	G.supplyCount[0]=0;
	G.supplyCount[1]=0;
	G.supplyCount[2]=0;
	gameOverTest = isGameOver(&G);
	if (gameOverTest==0) {//failed if still going 
		strncpy(passOrFail, "Failed normal supply test", sizeof (passOrFail));
	}
	printf("%s\n", passOrFail);

	
	//test out of bounds supply game end
	strncpy(passOrFail, "Passed supply test", sizeof (passOrFail));
	G.supplyCount[0]=-1;
	G.supplyCount[1]=-1;
	G.supplyCount[2]=-1;
	gameOverTest = isGameOver(&G);
	if (gameOverTest==0) {//failed if still going 
		strncpy(passOrFail, "Failed out of bounds supply test", sizeof (passOrFail));
	}
	printf("%s\n", passOrFail);

	return 0;
}
